package work;


public class Test03 {
    public static void main(String[] args) {
        char[] letters = new char[26];
        for (int i = 0; i < 26; i++) {
            letters[i] = (char) ('a' + i);
        }
        generateCombinations(letters, 0, new StringBuilder(), 0);
    }

    public static void generateCombinations(char[] letters, int mask, StringBuilder current, int length) {
        if (length <= 26) {
            System.out.println(current.toString());
        }else {
            return;
        }

        for (int i = 0; i < 26; i++) {
            if ((mask & (1 << i)) == 0) {
                current.append(letters[i]);
                generateCombinations(letters, mask | (1 << i), current, length + 1);
                current.setLength(current.length() - 1);
            }
        }
    }

}
